<template>
  <div class="app-container">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="业务员姓名">
        <el-input v-model="listQuery.name" />
      </el-form-item>

      <el-form-item label="手机号">
        <el-input v-model="listQuery.phone" />
      </el-form-item>

      <el-form-item label="所属级别">
        <el-select placeholder="请选择">
          <el-option label="--" value="shanghai"></el-option>
          <el-option label="全国" value="beijing"></el-option>
          <el-option label="省级主管" value="shanghai"></el-option>
          <el-option label="市级主管" value="beijing"></el-option>
          <el-option label="业务员" value="shanghai"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="业务员类型">
        <el-select placeholder="请选择">
          <el-option label="--" value="shanghai"></el-option>
          <el-option label="普通" value="beijing"></el-option>
          <el-option label="虚拟" value="shanghai"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="收货(省)">
        <el-select placeholder="请选择">
          <el-option label="北京市" value="shanghai"></el-option>
          <el-option label="天津市" value="beijing"></el-option>
          <el-option label="河北市" value="shanghai"></el-option>
          <el-option label="武汉市" value="shanghai"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="收货(市)">
        <el-select placeholder="请选择">
          <el-option label="--" value="shanghai"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="收货(区)">
        <el-select placeholder="请选择">
          <el-option label="--" value="shanghai"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="收货(道)">
        <el-select placeholder="请选择">
          <el-option label="--" value="shanghai"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="getList()">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="list" border style="width: 100%" >
      <el-table-column prop="name" label="业务员姓名">
        <template slot-scope="scope">
          <span>{{scope.row.name}}</span>
        </template>
      </el-table-column>

      <el-table-column prop label="身份证正面"></el-table-column>

      <el-table-column prop label="身份证反面"></el-table-column>

      <el-table-column prop="phone" label="手机号">
        <template slot-scope="scope">
          <span>{{scope.row.phone}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="levelStr" label="级别">
        <template slot-scope="scope">
          <span>{{scope.row.levelStr}}</span>
        </template>
      </el-table-column>

      <el-table-column prop label="负责范围"></el-table-column>

      <el-table-column prop="salesmanTypeStr" label="业务员类型">
        <template slot-scope="scope">
          <span>{{scope.row.salesmanTypeStr}}</span>
        </template>
      </el-table-column>

       <el-table-column prop="remark" label="备注">
        <template slot-scope="scope">
          <span>{{scope.row.remark}}</span>
        </template>
      </el-table-column>
      
       <el-table-column prop label="操作">
           <template slot-scope="scope">
          <el-dropdown trigger="click">
            <span class="el-dropdown-link">
              操作<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="openEdit(scope.row)">修改</el-dropdown-item>
              <el-dropdown-item @click.native="opensalesmans(scope.row)"> 选择业务员</el-dropdown-item>
              <el-dropdown-item @click.native="removes(scope.row)">解除绑定关系</el-dropdown-item>
              <el-dropdown-item  >修改范围</el-dropdown-item>
              <el-dropdown-item  >工作移交</el-dropdown-item>
              <el-dropdown-item @click.native="openfound(scope.row)">创建药店账号</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
       </el-table-column>

    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.showCount"
      @pagination="getList"
    />
    <edit ref="edit" />
    <removeBind ref="removeBind" />
    <salesmans ref="salesmans" />
  </div>
</template>

<script>
import apisalesman from "@/api/baseManager/salesman"
import Pagination from "@/components/Pagination";
import edit from "./dialogEdit"
import removeBind from './dialogRemoveBind'
import salesmans from './dialogChoiceSalesman'
import {confirm} from "@/utils/index";
 export default {
  name: "salesman",
  components: {Pagination , edit ,removeBind ,salesmans},
  data() {
    return {
      list: [],
      listQuery: {
        currentPage: 1,
        showCount: 10,
        name: "",
        phone: "",
        level: "",
        salesmanType: "",
        isDelete: 0,
        shqyP: "",
        shqyC: "",
        shqyA: "",
        shqyS: "",
        
      },
      total:0,
    };
  },
  created(){
      this.getList();
  },
  methods:{
      getList(){
          
          let data = apisalesman.getList()
          this.list = data.list;
          this.total = data.page.totalResult
      },
      //修改
    openEdit(row){
        this.$refs.edit.open(row.id)
    },
    //解除绑定关系
    removes(row){
        this.$refs.removeBind.open(row)
    },
    //选择业务员
    opensalesmans(row){
        this.$refs.salesmans.open(row)
    },
    //创建药店账号
    openfound(row){
        confirm('确定生成商城账号？').then(()=>{
            this.$message({type:"success",message:"重置成功！"});
        })
    }
  }
};
</script>

<style scoped>
</style>